/*
 * create by hanzhendong 2016/11/27
 * */
import { Component } from '@angular/core';

import { NavController, AlertController, MenuController } from 'ionic-angular';
import { DetailPage } from './detail/Detail';
import { ChatService } from '../../services/Chat';
import { HelpUtils } from "../../app/utils/HelpUtils";

@Component({
    selector: 'page-search',
    templateUrl: 'search.html'
})
export class SearchPage {
    searchQuery = {
        Name: "",
        RoleName: "",
        face: "",
        Phone: "",
        Email: "",
        Description: ""
    };
    items: Array<any> = [];

    constructor(public navCtrl: NavController, private alertCtrl: AlertController,private HelpUtils:HelpUtils,private ChatService: ChatService) {
        this.initializeItems()
    }


    initializeItems() {
        /*     this.ChatService.getChatList().then(chats => {
         this.items = chats;
         console.log(chats)
         });*/
        this.ChatService.getChatLists().subscribe(
            comments => this.items = comments||[],
            err => console.log(err))
        ;
    }

    NavigationTo(chat) {
        this.navCtrl.push(DetailPage, {chat});
    }


    /*
     * 打电话
     * */
    callPhone(params) {
        this.HelpUtils.callUp(params)
    }
}